import { CellRenderer } from "../../../../../fl/controls/listClasses/CellRenderer";
import { GTextFormat } from "../../../../common/GTextFormat";
import { FontUtil } from "../../../../common/font/FontUtil";
import { ResouceConst } from "../../../../component/gconst/ResouceConst";
import { ObjCreate } from "../../common/ObjCreate";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { Language } from "../../../../../extend/language/Language";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { SArenaBattle } from "../../../../../Message/Public/SArenaBattle";
import { CareerConfig } from "../../../resource/CareerConfig";
import { ScaleBitmap } from "../../../../../com/mui/display/ScaleBitmap";
import { GButton } from "../../../../../com/mui/controls/GButton";
//class ArenaBattleCellRenderer
    
    export  class ArenaBattleCellRenderer extends CellRenderer
    {
        constructor()
        {
            super();
            this.init();
            this.mouseChildren = true;
            return;
        }

        /* internal  */init(): void
        {
            this.initStyle();
            this.createChildren();
            this.addListeners();
            return;
        }

        /* internal  */initStyle(): void
        {
            this.setStyle("downSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("overSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("upSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("selectedDownSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("selectedOverSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("selectedUpSkin", new Object /* flash.display.Bitmap */());
            return;
        }

        /* internal  */createChildren(): void
        {
            this._textFromat = new GTextFormat(FontUtil.songtiName, 12, 11661311);
            this._textFromat.align = flash.text.TextFormatAlign.CENTER;
            this._line1 = ResouceConst.getScaleBitmap("SplitLine");
            this._line1.width = 230;
            this._line1.height = 2;
            this.addChild(this._line1);
            this._tfName1 = ObjCreate.createTextField("", 0, 8, 100, 20, this, this._textFromat);
            this._tfLevel1 = ObjCreate.createTextField("", 100, 8, 60, 20, this, this._textFromat);
            this._tfCareer1 = ObjCreate.createTextField("", 160, 8, 60, 20, this, this._textFromat);
            this._tfDuorenduizhan1 = ObjCreate.createTextField("多人对战模式", 0, 8, 220, 20, this, this._textFromat);
            this._tfDuorenduizhan1.visible = false;
            this._bmpVS = GlobalClass.getBitmap(ImagesConst.ArenaVS);
            ObjCreate.setObjAttri(this._bmpVS, 234, -7, -1, -1, this);
            this._line2 = ResouceConst.getScaleBitmap("SplitLine");
            this._line2.width = 230;
            this._line2.height = 2;
            this._line2.x = 275;
            this.addChild(this._line2);
            this._tfName2 = ObjCreate.createTextField("", 275, 8, 100, 20, this, this._textFromat);
            this._tfLevel2 = ObjCreate.createTextField("", 375, 8, 60, 20, this, this._textFromat);
            this._tfCareer2 = ObjCreate.createTextField("", 435, 8, 60, 20, this, this._textFromat);
            this._tfDuorenduizhan2 = ObjCreate.createTextField("多人对战模式", 275, 8, 220, 20, this, this._textFromat);
            this._tfDuorenduizhan2.visible = false;
            this._btnLook = ObjCreate.createGButton(Language.getString(42209), 505, 6, 55, 22, this);
            this._btnLook.drawNow();
            return;
        }

        /* internal  */addListeners(): void
        {
            this._btnLook.addEventListener(flash.events.MouseEvent.CLICK, this.onLookBtnClick);
            return;
        }

        /* internal  */onLookBtnClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._battleData) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.ArenaLookBattle, this._battleData.arenaId));
            }
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            if (typeof arg1 === "sarenabattle") 
            {
                this._battleData = arg1 as SArenaBattle;
                this.updateView();
            }
            return;
        }

        /* internal  */updateView(): void
        {
            var loc1=this._battleData.groupOne[0];
            var loc2=this._battleData.groupTwo[0];
            this._tfName1.text = loc1.name;
            this._tfLevel1.text = loc1.level.toString();
            this._tfCareer1.text = CareerConfig.instance.getInfoByCode(loc1.career).name;
            this._tfName2.text = loc2.name;
            this._tfLevel2.text = loc2.level.toString();
            this._tfCareer2.text = CareerConfig.instance.getInfoByCode(loc2.career).name;
            var loc3=this._battleData.groupOne.length > 1;
            var loc4=this._battleData.groupTwo.length > 1;
            this._tfName1.visible = !loc3;
            this._tfLevel1.visible = !loc3;
            this._tfCareer1.visible = !loc3;
            this._tfDuorenduizhan1.visible = loc3;
            this._tfName2.visible = !loc4;
            this._tfLevel2.visible = !loc4;
            this._tfCareer2.visible = !loc4;
            this._tfDuorenduizhan2.visible = loc4;
            return;
        }

        public /* override */ set label(arg1: string)
        {
            return;
        }

        /* internal */ /* var */_line1: ScaleBitmap;

        /* internal */ /* var */_tfDuorenduizhan1: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfName1: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfLevel1: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfCareer1: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfRank1: Object /* flash.text.TextField */;

        /* internal */ /* var */_bmpVS: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_line2: ScaleBitmap;

        /* internal */ /* var */_tfDuorenduizhan2: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfName2: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfLevel2: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfCareer2: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfRank2: Object /* flash.text.TextField */;

        /* internal */ /* var */_btnLook: GButton;

        /* internal */ /* var */_textFromat: Object /* flash.text.TextFormat */;

        /* internal */ /* var */_battleData: SArenaBattle;
    }
